home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / Graphic Elements 2 / Extras / Motion.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-18  |  1.1 KB  |  53 lines  |  [TEXT/MPS ]

  1. /*
  2.     Motion.h
  3.     
  4.     Simple motion routines for Graphic Elements
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/3/93
  9. */
  10.  
  11. #ifndef MOTIONPROCS
  12. #define MOTIONPROCS
  13.  
  14. #ifdef applec
  15. #ifndef __cplusplus
  16. #ifndef PRELOAD
  17. #pragma load "::ToolKit.precompile"
  18. #define PRELOAD
  19. #endif
  20. #endif
  21. #endif
  22.  
  23. #include "DispCtrl.h"
  24.  
  25. typedef struct {
  26.     Rect    limitRect;
  27.     Point    currMotion;
  28.     long    friction;    //coeff. of friction, %
  29.     long    frictAcc;    //Actually fixed-point
  30.     long    elasticity; //coeff. of elasticity
  31. } MotionParams, *MParamPtr;
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. //Initialize MotionParams record
  38. void InitMotion(MParamPtr motionRec, short percentFriction, short percentElasticity);
  39.  
  40. //Returns direction (right, left, up, down only) of collision with limitRect
  41. GEDirection CheckLimits(Rect *spriteRect, Rect *limitRect);
  42.  
  43. //Modifies motion->currMotion to reflect motion->friction
  44. void DoFriction(MParamPtr motion);
  45.  
  46. //Modifies motion->currMotion to reflect bounce in direction, taking into account motion->elasticity
  47. void DoBounce(VHSelect direction, MParamPtr motion);
  48.  
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52.  
  53. #endif